import { View } from "../../../mvc/core/View";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { LayerManager } from "../../manager/LayerManager";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Language } from "../../../../extend/language/Language";
import { Cache } from "../../cache/Cache";
import { ETaskGroup } from "../../../../Message/Game/ETaskGroup";
import { ENpcEffect } from "../../../../Message/Public/ENpcEffect";
import { AIManager } from "../../scene/ai/AIManager";
import { AIType } from "../../scene/ai/AIType";
import { EffectManager } from "../../manager/EffectManager";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class CareerChangeIcon
    
    export  class CareerChangeIcon extends View
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            buttonMode = true;
            this._loadedBtn = ObjCreate.createGLoadedButton(ResFileConst.CareerChangeIcon, 0, 0, 60, 50, this);
            addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            layer = LayerManager.rightTopUILayer;
            return;
        }

        protected onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Alert.showCloseBtn = true;
            Alert.okLabel = Language.getString(27521);
            Alert.calcelLabel = Language.getString(27522);
            Alert.show(Language.getString(27523), Language.getString(27502), Alert.OK | Alert.CANCEL, null, this.onAlertClickHandler);
            return;
        }

        /* internal  */onAlertClickHandler(arg1: int): void
        {
            var loc1=null;
            var loc2=null;
            if (Cache.instance.task.hasTaskByGroup(ETaskGroup._ETaskGroupChangeCareer)) 
            {
                loc2 = Cache.instance.task.getTaskByGroup(ETaskGroup._ETaskGroupChangeCareer)[0];
                loc1 = loc2.getTargetByIndex(0);
            }
            else 
            {
                loc1 = Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectCareerChange);
            }
            if (arg1 != Alert.OK) 
            {
                if (arg1 == Alert.CANCEL) 
                {
                    AIManager.onAIControl(loc1, AIType.AI_Convey);
                }
            }
            else 
            {
                AIManager.onAutoPathAIControl(loc1);
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            EffectManager.glowFilterReg(this, [FilterConst.guideTipsFilter], 0.6, 10, 5, 20);
            return;
        }

        protected /* var */_loadedBtn: GLoadedButton;
    }
